<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/public/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>待办列表</title>

 <%@ include file="/WEB-INF/page/public/contentmeta.jsp"%>
<link rel="stylesheet" href="<%=basePath%>css/global.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>plugins/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" href="<%=basePath%>css/system.css" media="all">
<style type="text/css">
/*table*/
.site-table thead { background:url(../images/thead-bg.png) repeat-x; height:36px; color:#2591D0; }
.site-table thead tr:hover { background:none!important; }
.site-table th, .site-table td { border:0; text-align:center; margin:0 0 0 30px; }
.site-table tr { cursor:default; }
.site-table tr:last-child { border:1px solid #e4e4e4; }
.site-table tr:first-child { border-top:0; }
.site-table tr { border:1px solid #e4e4e4; }
.site-table td { height:28px; line-height:28px; }
.site-table .co-address:hover { color:#2591D0; text-decoration:underline; } 
/*.site-table .layui-btn-mini { background-color:#e4bd48; padding:0 10px; }*/
.site-table .layui-btn-disabled.active { background-color:#dfdfdf; color:#fff; }
.site-table .none-info { color:#f36563; }
.site-table tr.active,
.site-table tr:hover { background-color:#eee; } 
.site-table thead tr:hover { background-color:#d8eff7; }
.site-table tr.active td,
.site-table tr:hover td { height:28px; line-height:28px; }
.site-table.TM-table3 th, .site-table.TM-table3 td { text-align:left; margin:0; }
.site-table td a { cursor:pointer; }
.site-table.TM-table3 th:first-child,
.site-table.TM-table3 td:first-child { text-align: center; }
.TM-table3 .layui-btn-primary:hover { border-color:#2591D0; }
</style>
</head>
<body>

 	<div id="TM-wrap-tab1" >
				<div class="TM-layui-tab1">
					<table class="site-table table-hover TM-table3"  style="text-align:left; margin:0;" >
						<thead>
						<tr>
							<th style="width:20%;">客户名称</th>
							<th style="width:10%;">预约时间</th>
							<th style="width:40%;">备注信息</th>
							<th style="width:10%;">成熟度等级</th>
							<th style="width:20%;"></th>
						</tr>
						</thead>
						<tbody>
						<c:forEach items="${pager.resultList}" var="todoObj">
							<tr>
								<td><a target="_blank" href="/customer/updatecustomer${todoObj.cusid}"       class="TM_hover ">${todoObj.customerInfo.cname}</a></td>
								<td>${todoObj.stime}</td>
								<td>${todoObj.remark}</td>
								<td><dic:cf value="${todoObj.customerInfo.state}" name="customer_state" type="1"/> </td>
								<td>
									<button class="layui-btn contactIn layui-btn-mini"  cid="${todoObj.customerInfo.id}"  cdid="${todoObj.id}" cusid="${todoObj.cusid}">设为已联系</button>
								</td>
							</tr> 
						</c:forEach> 
						</tbody>
					</table>
					<div class="admin-table-page">
						<div id="page" class="page"></div>
					</div>
				</div>
			</div>
			
		<!--联系记录 -->
<div id="TM-layui-askFor" style="display:none;">
  <form class="layui-form" id="tjlxjlForm" action="">
      <div class="layui-form-item address" style="margin-top:10px">
            <label class="layui-form-label">联系人： </label>
            <div class="layui-input-block" style="width:60%">
                  <select name="contact" id="contact"  lay-filter="contact"  >
                    	<option value="">请选择</option>
                 </select>
            </div>
        </div>
	     <div class="layui-form-item layui-form-text">
		    <label class="layui-form-label">备注：</label>
		    <div class="layui-input-block" style="width:60%">
		      <textarea id="remark" name="remark" placeholder="请输入内容" class="layui-textarea"></textarea>
		        <input name="id" id="jlid" type="hidden" value=""   >
		        <input type="hidden" id="h_cusid" value="">
		    </div>
		  </div>
    </form>
</div>
	
	
  <form class="layui-form TM-entering-form" action="/user/mytodolist" id="yytxform"  method="get">
      <input name="skipToPage" id="skipToPage"  type="hidden" value="${pager.pageNo}"   > 
  
  </form>
	
	<script>
    layui.use(['laypage','form','laydate'], function() {
        var $ = layui.jquery,
                layer = layui.layer,
                laypage = layui.laypage;
                var form = layui.form();
                
               // 
            $(".co-address").on("click",function(){
            		var id = $(this).attr("data");
            		var url = "/customer/customerinfo1/c"+id;
            		parent.layer.open({
            			  	type:2,
            	  		title:"企业详情",
            	  		shadeClose:true,
            	  		content: url,
            	  		area:['80%','95%'],
            	  		maxWidth:1000,
            		});
            });         
                       
               
        $("#tjlxjlForm").validate({
        	rules: {
        		contact : {
	    			required:true,
	    		},
	    		remark: {
	    			required:true, 
	    		}
	    	},
	    	messages: {
	    		contact : {
	    			required:"请选择联系人",
	    		},
	    		remark: {
	    			required:"请填写备注",
	    		} 
	    	},
	    	errorPlacement: function(error, element) {
				layer.tips(error.text(), element, {
					tips: [2,tipColor],
	     		 tipsMore: true
	     		});
	   		}, 
	   	 submitHandler: function(form) {
	   		    var cuid = $("#contact").val(),remark=$("#remark").val(),cdid=$("#jlid").val(); 
	   		 	var cusid = $("#h_cusid").val();
             	$.ajax({
   		 		type : "post",
   		 		url : "/customer/addcontactsdynamicinfo",
   		 		data : {id:cdid,cusid:cusid,ccuid:cuid,remark:remark},
   		 		dataType : "json",
   		 		async : false,
   		 		success : function(data){
   		 		    if(data==1){
   		 		       layer.closeAll();
   		 		       layer.msg("添加联系记录成功", {  icon: 1  },function(){ window.location.href = "/user/mytodolist"; });  
   		 		    }else{
   		 		       layer.msg("添加联系记录失败", {  icon: 2  });  
   		 		    }
   		 		}
   		 	});  
	   	 
	      }
        });
               
                
                //联系记录弹窗
                $('.contactIn').on('click',function(){
                   var cid = $(this).attr("cid"),cdid = $(this).attr("cdid");
                   var cusid = $(this).attr("cusid");
                	$.ajax({
        		 		type : "post",
        		 		url : "/customer/customerinfoajax",
        		 		data : {id:cid},
        		 		dataType : "json",
        		 		async : false,
        		 		success : function(data){
        		 			var html ="";
        		 		    var contacts =	data.contactsItem;
        		 		    var cname = data.cname; 
        		 		    if(contacts!=null&&contacts.length>0){
        		 		    	for(var i =0;i<contacts.length;i++){
        		 		    		 html+="<option value='"+contacts[i].id+"'>"+contacts[i].name+"(电话："+contacts[i].phone+")</option>";
        		 		    	} 
        		 		    	$("#contact").html(html);
        		 		    }else{
        		 		    	$("#contact").html("<option value=''>请选择联系人</option>");
        		 		    }
        		 			form.render(); 
        		 			 layer.open({
        	                        type:1,
        	                        content:$('#TM-layui-askFor'),
        	                        btn:['确定','取消'],
        	                        btnAlign:'c',
        	                        shadeClose:true,
        	                        title:cname+'添加联系记录',
        	                        area:['600px','300px'],
        	                        maxWidth:800,
        	                        yes: function(layero, index){
        	                             $("#jlid").val(cdid);
        	                             $("#h_cusid").val(cusid);
        	                        	$("#tjlxjlForm").submit();
        	                        }
        	                 });
        		 		}
        		 	});
                });

                //分页
                 laypage({
                    cont: 'page',
                    curr:'${pager.pageNo}'
                    ,pages: '${pager.totalPages}' //总页数
                    ,
                    groups: 5 //连续显示分页数
                    ,
                    jump: function(obj, first) {
                        //得到了当前页，用于向服务端请求对应数据
                        var curr = obj.curr;
                        if(!first) {
                        	$("#skipToPage").val(curr);
                        	$("#yytxform").submit();
                        	
                        }
                    }
                });         
    })     
    </script>
</body>
</html>
